package cn.javass.dp.chianofresponsibility.example5;

public class DepManager2 extends DepManager {


    @Override
    public Object handleRequest(RequestModel rm) {
        System.out.println("54321");
        if (PreFeeRequestModel.FEE_TYPE.equals(rm.getType())) {
            // 表示预支费用
            return myHandle(rm);
            //
        } else {
            return super.handleRequest(rm);
        }
    }

    private Object myHandle(RequestModel rm) {
        PreFeeRequestModel frm = (PreFeeRequestModel) rm;
        if (frm.getFee() < 20000) {
            System.out.println("部门经理同意"+frm.getUser()+"预支差旅费"+frm.getFee()+"元");
            return true;
        } else {
            if (successor != null) {
                return this.successor.handleRequest(rm);
            }
        }
        return false;
    }

/*    @Override
    public boolean handlePreFeeRequest(String user, double requestNum) {
        if (requestNum < 20000) {
            System.out.println("部门经理同意"+user+"预支差旅费"+requestNum+"元");
            return true;
        } else {
            if (successor != null) {
                return this.successor.handlePreFeeRequest(user, requestNum);
            }
        }
        return false;
    }*/
}
